package my.test.bean.ex12.aspect;

import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AServiceImpl1 implements AService{

	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@Transactional(propagation = Propagation.REQUIRED)
	@Override
	public void a() {
		// TODO Auto-generated method stub
        //this.b();
		((AService)(AopContext.currentProxy())).b();
		throw new RuntimeException();
	}

	@Transactional(propagation = Propagation.REQUIRES_NEW)
	@Override
	public void b() {
		// TODO Auto-generated method stub
		jdbcTemplate.update("INSERT INTO t1 VALUES (?, ?, ?, ?, ?)",
				"1","1","1","1","1");		
	}

}
